//
//  RootViewController.m
//  UI6_UIScrollView_UIPageControl相册作业
//
//  Created by dllo on 15/11/14.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootViewController.h"
#import "IconViewController.h"
#import "ListViewController.h"
#import "PhotoViewController.h"

@interface RootViewController ()

@property (nonatomic, retain) IconViewController *iconVC;
@property (nonatomic, retain) ListViewController *listVC;
@property (nonatomic, retain) PhotoViewController *photoVC;


@end

@implementation RootViewController


//- (void)dealloc
//{
//    [_iconVC release];
//    [_listVC release];
//    [_photoVC release];
//
//    [super dealloc];
//}





- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.view.backgroundColor = [UIColor whiteColor];
//    
//    
//    self.iconVC = [[IconViewController alloc] init];
//    [self addChildViewController:self.iconVC];
//    [self.view addSubview:self.iconVC.view];
//    [_iconVC release];
//    
//
//    
//    
//    self.listVC = [[ListViewController alloc] init];
//    [self addChildViewController:self.listVC];
//    [self.view addSubview:self.listVC.view];
//    [_listVC release];
//    
//    
//    self.photoVC = [[PhotoViewController alloc] init];
//    [self addChildViewController:self.photoVC];
//    [self.view addSubview:self.photoVC.view];
//    [_photoVC release];
    
    
    
    UISegmentedControl *segmentC = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"缩略图", @"列表", nil]];
    segmentC.center = CGPointMake(200, 40);
//    segmentC.backgroundColor = [UIColor blackColor];
//    segmentC.selectedSegmentIndex = 0;
    [segmentC addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
//    [self.view bringSubviewToFront:segmentC];
        self.navigationItem.titleView = segmentC;
    [self.view addSubview:segmentC];
    [segmentC release];
    

    

    
    
    
}

- (void)segmentAction:(UISegmentedControl *)sender
{
    if (0 == sender.selectedSegmentIndex) {
        IconViewController *iconVC = [[IconViewController alloc] init];
//        [self presentViewController:iconVC animated:YES completion:^{
//        
//            
//        }];
        [self.navigationController pushViewController:iconVC animated:YES];
        
        [iconVC release];
//        [self.view bringSubviewToFront:self.iconVC.view];
//         [self.view bringSubviewToFront:sender];
    }
    if (1 == sender.selectedSegmentIndex) {
        ListViewController *listVC = [[ListViewController alloc] init];
//        [self presentViewController:listVC animated:YES completion:^{
//            
//            
//        }];
         [self.navigationController pushViewController:listVC animated:YES];
        [listVC release];
//        [self.view bringSubviewToFront:self.listVC.view];
//         [self.view bringSubviewToFront:sender];
    }
        [self.view bringSubviewToFront:sender];
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
